package com.lele.file;

import java.io.IOException;

import com.lele.util.FolderUtil;

public class DAOFile extends SuperFile {
	public DAOFile(SuperFile sf) {
		this.project_root = sf.getProject_root();
		this.file_url = sf.getFile_url() + "\\daoimpl\\" + sf.getEntityName() + "\\";
		this.package_url = sf.getPackage_url() + "\\daoimpl\\" + sf.getEntityName();
		this.entityClass = sf.getEntityClass();
		this.entityName = sf.getEntityName();
	}

	public DAOFile() {

	}

	public String getFileURL() {
		StringBuilder s = new StringBuilder();
		s = s.append(file_url).append(entityClass).append("DAO")
				.append(".java");
		return s.toString();
	}

	public String getContent() {
		StringBuilder s = new StringBuilder();
		String head_package = package_url.replace("\\", ".");
		String build = System.getProperty("user.dir")
				+ "\\src\\template\\ManagerDAO.txt";
		try {
			s.append(FolderUtil.readTxt(build.toString(), "UTF-8")
					.replace("template", head_package)
					.replace("Manager", entityClass)
					.replace("manager", entityName));

		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return s.toString();
	}
}
